// 导入依赖
const express = require('express')
const cfg = require('./config/config')
const mycors = require('./middleware/MyCros')
// 导入数据库处理控制器
const userController = require('./controller/userController')
const articlesController = require('./controller/articlesController')
const birdsController = require('./controller/birdsController')
const commentController = require('./controller/commentController')
const favoritesController = require('./controller/favoritesController')
// const gotDevice = require('./controller/ai')
// 创建app
const userRouter = require('./controller/userController');
const app = express()
app.use(mycors)
app.use(express.json()); // 用于解析 application/json
app.use(express.urlencoded({ extended: true })); // 解析表单数据
app.use('/user', userController)
app.use('/articles', articlesController)
app.use('/birds', birdsController)
app.use('/comment', commentController)
app.use('/favorites', favoritesController)
app.use('/users', userRouter); // 注意这里是复数形式
app.listen(5000, () => {
  console.log('服务已启动，监听端口5000')
})
